package com.itheima.hibernate.utils;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

/**
 * Hibernate的工具类
 * 
 * @author unicorn
 * @version v1.0
 * @createTime 2019年2月21日 下午1:48:23
 */
public class HibernateUtils {

	private static final Configuration cfg;
	private static final SessionFactory sf;
	
	static {
		cfg = new Configuration().configure();
		sf =  cfg.buildSessionFactory();
	}
	
	public static Session openSession() {
		return sf.openSession();
	}
	
	public static Session getCurrentSession() {
		return sf.getCurrentSession();
	}
}
